﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;

namespace NetScraperLibrary
{
    public class NetScraper
    {
        #region Data Members

        #endregion

        #region Properties 

        #endregion

        #region Constructors

        public NetScraper()
        {
        }

        #endregion

        #region Methods

        public ScrapedPage GetPage(string uri)
        {

            WebRequest request = WebRequest.Create(uri);
            StreamReader response = new StreamReader(request.GetResponse().GetResponseStream());
            StringBuilder sb = new StringBuilder();
            string line;

            // Copy the response stream 
            while ((line = response.ReadLine()) != null)
            {
                if (line.Length > 0)
                    sb.Append(line);
            }

            response.Close();

            ScrapedPage page = new ScrapedPage(uri, sb.ToString());

            return page;
        }

        #endregion

        #region Garbage Collection

        #endregion
    }
}
